﻿using NHibernate;
using NHibernate.Mapping;
using Shake.Domain.Infrastructures;
using Shake.Framework.Infrastructure;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Shake.Framework.Repository
{
    public interface IRepository
    {
        void Delete<T>(T entity) where T : ShakeEntity;
        void DeleteMany<T>(IEnumerable<T> entities) where T : ShakeEntity;

        void Insert<T>(T entity) where T : ShakeEntity;
        void InsertMany<T>(IEnumerable<T> entities) where T : ShakeEntity;

        void Update<T>(T entity) where T : ShakeEntity;
        void UpdateMany<T>(IEnumerable<T> entities) where T : ShakeEntity;

        /// <summary>
        /// 更新实体，并且可以指定一个关系实体进行更新
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="T2"></typeparam>
        /// <param name="entity"></param>
        /// <param name="Associate">指定要更新的实体导航</param>
        //void UpdateGraph<T, T2>(T entity, Expression<Func<T, ICollection<T2>>> Associate) where T : ShakeEntity, new();

        IList<T> Query<T>() where T : ShakeEntity;

        ISessionFactory CreateSessionFactory();
    }
}
